ServerEvents.recipes(event =>{
  var outputs_al=['immersiveengineering:connector_hv','immersiveengineering:connector_hv_relay','immersiveengineering:alu_scaffolding_standard','immersiveengineering:alu_fence','immersiveengineering:connector_hv','immersiveengineering:plate_aluminum','immersiveengineering:plate_aluminum']  
  outputs_al.forEach(i=>{
    event.replaceInput({"output":i},'immersiveengineering:ingot_aluminum','kubejs:aluminum_alloy')
  })
  event.remove({type:"alchemistry:dissolver"})
  event.remove({type:"tfc:heating",input:['tfc_ie_addon:powder/bauxite','tfc_ie_re:ore/small_bauxite','tfcorewashing:pellet_bauxite','tfcorewashing:briquet_bauxite']})
  event.remove({type:"alchemistry:combiner",not:{output:["#minecraft:logs","#forge:foods","minecraft:redstone"]}})
  event.remove({output:'createnuclear:uranium_powder'})
  event.remove({input:'createnuclear:uranium_powder'})
  event.replaceInput({output:['createnuclear:reactor_gauge','createnuclear:reactor_cooling_frame','createnuclear:reactor_core']},'createnuclear:steel_ingot','kubejs:titanium_aluminum_alloy')
  //
  function dissolver1(inputs,outputs){
        var result=[]
        outputs.forEach(i=>{
            result.push({"count":i[0],"item":i[1]})
        })
        event.custom({
            "type": "alchemistry:dissolver",
            "group": "alchemistry:dissolver",
            "input": {
              "count":  inputs[0],
              "ingredient": {
                "item": inputs[1]
              }
            },
            "output": {
              "groups": [
                {
                  "probability": 100.0,
                  "results": result
                }
              ],
              "rolls": 1,
              "weighted": false
            }
          })
    }
  function dissolver2(inputs,outputs){
      var result=[]
      outputs.forEach(i=>{
          result.push({"count":i[0],"item":i[1]})
      })
      event.custom({
          "type": "alchemistry:dissolver",
          "group": "alchemistry:dissolver",
          "input": {
            "count":  inputs[0],
            "ingredient": {
              "tag": inputs[1]
            }
          },
          "output": {
            "groups": [
              {
                "probability": 100.0,
                "results": result
              }
            ],
            "rolls": 1,
            "weighted": false
          }
        })
  }
    dissolver1([16,"tfc:powder/salt"],[[1,"chemlib:potassium_chloride_dust"],[1,"chemlib:calcium_chloride_dust"],[1,"chemlib:magnesium_chloride_dust"],[13,"chemlib:sodium_chloride_dust"]])
    dissolver1([5,"tfc:powder/wood_ash"],[[2,"chemlib:sodium_carbonate_dust"],[2,"chemlib:potassium_chloride_dust"],[1,"chemlib:phosphoric_acid_dust"]])
    dissolver2([1,"minecraft:logs"],[[4,"chemlib:cellulose"]])

    //分解和合成食物
    const meat_tags=['forge:raw_fishes','forge:cooked_fishes','forge:foods/meat/raw','forge:foods/meat/cooked']
    meat_tags.forEach(i =>{
      dissolver2([1,i],[[4, 'chemlib:protein']])
    })
    dissolver2([1,'forge:glue'],[[2, 'chemlib:protein'],[2,'chemlib:sucrose']])
    dissolver1([1,'minecraft:rotten_flesh'],[[1,'chemlib:protein']])
    dissolver2([2,'forge:seeds'],[[1,"chemlib:cellulose"]])
    dissolver1([1,'tfc:food/sugarcane'],[[1,'chemlib:sucrose','chemlib:cellulose']])
    dissolver1([20,'minecraft:beetroot'],[[20,'chemlib:sucrose'],[1,'chemlib:iron_oxide']])
    dissolver1([1,'firmalife:raw_honey'],[[2,'chemlib:sucrose']])
    dissolver2([3,'forge:fruits/berries'],[[2,'chemlib:sucrose'],[1,'chemlib:cellulose']])

    function compactor(input,output){
      event.custom({
        "type": "alchemistry:compactor",
        "group": "alchemistry:compactor",
        "input": {
          "count": input[0],
          "ingredient": {
            "item": input[1]
          }
        },
        "result": {"count":output[0],"item":output[1]}
      })
    }
    compactor([10,'tfcorewashing:briquet_uraninite'],[1,'createnuclear:uranium_powder'])
    
    function liquifier(input,output){
      event.custom({
        "type": "alchemistry:liquifier",
        "group": "alchemistry:liquifier",
        "input": {
          "count": input[0],
          "ingredient": {
            "item": input[1]
          }
        },
        "result": {
          "amount": output[0],
          "fluid": output[1]
        }
      })
    }
    liquifier([1,'createnuclear:uranium_powder'],[25,'createnuclear:uranium'])
    event.shaped(Item.of('custommachinery:custom_machine_item','{machine:"kubejs:electrolytic_chamber"}'),[
        'ABCBA','ADEDA','AFGFA','AAAAA'
    ],{
        'A':'#anvilcraft:reinforced_concrete',
        'B':'immersiveengineering:component_electronic_adv',
        'C':'ae2:semi_dark_monitor',
        'D':'immersiveengineering:wirecoil_steel',
        'E':'thermal:machine_frame',
        'F':'#minecraft:terracotta',
        'G':'thermal:charge_bench'
    })
  const custom=event.recipes.custommachinery.custom_machine
  function machinery(){
    //电解铝
      custom("kubejs:electrolytic_chamber",3000)
      .requireFluid(Fluid.of('tfc_ie_addon:metal/aluminum',4800))
      .requireItem("5x tfc:ore/cryolite")
      .requireItem("2x immersiveengineering:dust_hop_graphite","slot3")
      .requireEnergy(4000000)
      .produceItem("15x minecraft:redstone","slot4")
      .produceFluid(Fluid.of('kubejs:melting_high_purity_aluminum',4800))
      .produceFluid(Fluid.of('chemlib:carbon_dioxide_fluid',2400))

      custom("kubejs:electrolytic_chamber",3000)
      .requireFluid(Fluid.of('tfc_ie_addon:metal/aluminum',2000))
      .requireItem(Item.of('enderio:powdered_coal',16),"slot3")
      .requireEnergy(6000000)
      .produceFluid(Fluid.of('kubejs:melting_high_purity_aluminum',2000))
      .produceFluid(Fluid.of('chemlib:carbon_dioxide_fluid',1000))

      custom("kubejs:electrolytic_chamber",200)
      .requireFluid(Fluid.of('tfc:salt_water',500))
      .requireItem("5x chemlib:sodium_chloride_dust")
      .requireEnergy(102400)
      .produceItem("15x chemlib:sodium_hydroxide_dust","slot4")
      .produceItem("immersiveengineering:slag","slot5")
      .produceFluid(Fluid.of('chemlib:hydrogen_fluid',500))
      .produceFluid(Fluid.of('chemlib:chlorine_fluid',500))
      //
      custom("kubejs:reaction_kettle",200)
      .requireFluid(Fluid.of('tfc:limewater',100))
      .requireItem('2x chemlib:sodium_carbonate_dust')
      .produceItem('2x chemlib:sodium_hydroxide_dust')
      .produceItem('chemlib:calcium_carbonate_dust')
      .requireEnergy(25600)
      //氧化铝获取
      custom("kubejs:reaction_kettle",200)
      .requireFluid(Fluid.of('kubejs:purified_water',200))
      .requireItem('10x tfcorewashing:pellet_bauxite')
      .requireItem('2x chemlib:sodium_hydroxide_dust')
      .requireEnergy(51200)
      .produceFluid(Fluid.of("kubejs:sodium_aluminate",200))

      custom("kubejs:reaction_kettle",500)
      .requireFluid(Fluid.of("kubejs:sodium_aluminate",100))
      .requireFluid(Fluid.of("chemlib:carbon_dioxide_fluid",500))
      .requireEnergy(51200)
      .produceItem('chemlib:aluminum_oxide_dust')
      .produceItem('chemlib:sodium_carbonate_dust')
      .produceFluid(Fluid.of("minecraft:water",100))

      custom("kubejs:reaction_kettle",500)
      .requireItem('1x chemlib:aluminum_oxide_dust')
      .requireEnergy(25600)
      .produceFluid(Fluid.of("tfc_ie_addon:metal/aluminum",100))
    }
    machinery()
  })